﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.IO;

namespace RenjianImageViewer.Util
{
    static class ExtensionMethod
    {
        public static XElement ParseToXElement(this string xmlText)
        {
            XElement result = null;
            try
            {
                result = XElement.Parse(xmlText);
            }
            catch
            {
                System.Xml.XmlReaderSettings xrs =
                    new System.Xml.XmlReaderSettings { CheckCharacters = false };
                using (System.Xml.XmlReader xr = System.Xml.XmlReader.Create(new StringReader(xmlText), xrs))
                {
                    result = XElement.Load(xr);
                }
            }
            return result;
        }
    }
}
